﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Sinacor.Servico.Bovespa.Ordens.Service.ServiceImplementation.Translator.DataContractToBusinessEntity
{
    public static class Motivo
    {
        public static BusinessEntity.Parameter.FiltroMotivo ToFiltroMotivo(DataContract.Request.FiltroMotivoRequest from)
        {
            BusinessEntity.Parameter.FiltroMotivo to = null;

            if (from != null)
            {
                to = new Sinacor.Servico.Bovespa.Ordens.BusinessEntity.Parameter.FiltroMotivo();

                to.Codigo = from.Codigo;
                to.Descricao = from.Descricao;
            }

            return to;
        }

        public static List<BusinessEntity.Parameter.FiltroMotivo> ToFiltroMotivo(List<DataContract.Request.FiltroMotivoRequest> from)
        {
            List<BusinessEntity.Parameter.FiltroMotivo> to = null;

            if (from != null)
            {
                to = new List<Sinacor.Servico.Bovespa.Ordens.BusinessEntity.Parameter.FiltroMotivo>();

                foreach (DataContract.Request.FiltroMotivoRequest item in from)
                {
                    to.Add(ToFiltroMotivo(item));
                }
            }

            return to;
 
        }

        public static BusinessEntity.Motivo ToMotivo(DataContract.Request.MotivoRequest from)
        {
            BusinessEntity.Motivo to = null;

            if (from != null)
            {
                to = new Sinacor.Servico.Bovespa.Ordens.BusinessEntity.Motivo();

                to.Codigo = from.Codigo;
                to.Descricao = from.Descricao;
            }

            return to;
 
        }

        public static List<BusinessEntity.Motivo> ToMotivo(List<DataContract.Request.MotivoRequest> from)
        {
            List<BusinessEntity.Motivo> to = null;

            if (from != null)
            {
                to = new List<Sinacor.Servico.Bovespa.Ordens.BusinessEntity.Motivo>();

                foreach (DataContract.Request.MotivoRequest item in from)
                {
                    to.Add(ToMotivo(item));
                }
            }

            return to;
 
        }
    }
}
